package std.game.objects.views;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

import junit.framework.TestCase;

import org.easymock.MockControl;
import org.groovymud.object.MudObject;
import org.groovymud.object.alive.Alive;
import std.game.objects.views.ContentsHelper

public class ContentsHelperTest extends TestCase {
	
	public void testGetContentsDescription() {
		Set objects = new HashSet();
		MudObject obj = [isArticleRequired: {true}, getName : {"something"}] as MudObject
		objects.add(obj)
		Set objects2 = new HashSet();
		Alive two = [:] as Alive;
		objects.add(two)	
		Map<String, Set<MudObject>> contents = new TreeMap<String, Set<MudObject>>();
		contents.put("something", objects);
		contents.put("somethingelse", objects2);
		
		ContentsHelper helper = new ContentsHelper();
		String desc = helper.getContentsDescription(contents, (Alive) two, true);
		assertEquals("A something", desc)
	}
	
	public void testGetContentsDescriptionTwoOthers() {

		
		Set<MudObject> objects = new HashSet<MudObject>();
		MudObject obj1 = [isArticleRequired: {true}, getName : {"something"}] as MudObject
		
		MudObject obj2 = [isArticleRequired: {true}, getName : {"something"}] as MudObject
		
		objects.add(obj1);
		objects.add(obj2);
		
		Alive player = [:] as Alive;
		
		objects.add(player);
		
		Set<MudObject> objects2 = new HashSet<MudObject>();
		MudObject obj3 = [isArticleRequired: {false}, getName : {"one more"}] as MudObject
		
		objects2.add(obj3);
		
		Map<String, Set<MudObject>> contents = new TreeMap<String, Set<MudObject>>();
		contents.put("something", objects);
		contents.put("one more", objects2);
		
		ContentsHelper helper = new ContentsHelper();
		String desc = helper.getContentsDescription(contents, (Alive) player, true);
		assertEquals("One more and two somethings", desc);
		
	}
	public void testGetContentsDescriptionTwoOthersAndAnotherThing() {
		
		
		Set<MudObject> objects = new HashSet<MudObject>();
		MudObject obj1 = [isArticleRequired: {true}, getName : {"something"}] as MudObject
		
		MudObject obj2 = [isArticleRequired: {true}, getName : {"something"}] as MudObject
		
		objects.add(obj1);
		objects.add(obj2);
		
		Alive player = [:] as Alive;
		
		objects.add(player);
		
		Set<MudObject> objects2 = new HashSet<MudObject>();
		MudObject obj3 = [isArticleRequired: {false}, getName : {"one more"}] as MudObject
		
		objects2.add(obj3);
		Set<MudObject> objects3 = new HashSet<MudObject>();
		MudObject obj4 = [isArticleRequired: {false}, getName : {"another thing"}] as MudObject
		
		objects3.add(obj4);
		
		Map<String, Set<MudObject>> contents = new TreeMap<String, Set<MudObject>>();
		contents.put("something", objects);
		contents.put("one more", objects2);
		contents.put("another thing", objects3);
		ContentsHelper helper = new ContentsHelper();
		String desc = helper.getContentsDescription(contents, (Alive) player, true);
		assertEquals("Another thing, one more and two somethings", desc);
		
	}
	public void testGetContentsDescriptionTwoOthersAndAnotherThingEtc() {
		
		
		Set<MudObject> objects = new HashSet<MudObject>();
		MudObject obj1 = [isArticleRequired: {true}, getName : {"something"}] as MudObject
		
		MudObject obj2 = [isArticleRequired: {true}, getName : {"something"}] as MudObject
		
		objects.add(obj1);
		objects.add(obj2);
		
		Alive player = [:] as Alive;
		
		objects.add(player);
		
		Set<MudObject> objects2 = new HashSet<MudObject>();
		MudObject obj3 = [isArticleRequired: {false}, getName : {"one more"}] as MudObject
		
		objects2.add(obj3);
		Set<MudObject> objects3 = new HashSet<MudObject>();
		MudObject obj4 = [isArticleRequired: {false}, getName : {"another thing"}] as MudObject
		
		objects3.add(obj4);
		
		
		Set<MudObject> objects4 = new HashSet<MudObject>();
		MudObject obj5 = [isArticleRequired: {false}, getName : {"yet another"}] as MudObject
		
		objects4.add(obj5);
		
		Map<String, Set<MudObject>> contents = new TreeMap<String, Set<MudObject>>();
		contents.put("something", objects);
		contents.put("one more", objects2);
		contents.put("another thing", objects3);
		contents.put "yet another", objects4
		ContentsHelper helper = new ContentsHelper();
		String desc = helper.getContentsDescription(contents, (Alive) player, true);
		assertEquals("Yet another, another thing, one more and two somethings", desc);
		
	}
}
